package com.ruoyi.qiju.service.impl;

import java.util.List;

import com.ruoyi.consent.domain.AlgsEquipmentConsent;
import com.ruoyi.consent.mapper.AlgsEquipmentConsentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.qiju.mapper.AlgsEquipmentApplicationMapper;
import com.ruoyi.qiju.domain.AlgsEquipmentApplication;
import com.ruoyi.qiju.service.IAlgsEquipmentApplicationService;

import javax.annotation.Resource;

/**
 * 实验器材申请Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-03-21
 */
@Service
public class AlgsEquipmentApplicationServiceImpl implements IAlgsEquipmentApplicationService 
{
    @Autowired
    private AlgsEquipmentApplicationMapper algsEquipmentApplicationMapper;
    @Resource
    private AlgsEquipmentConsentMapper algsEquipmentConsent1;
    /**
     * 查询实验器材申请
     * 
     * @param equipmentApplicationId 实验器材申请主键
     * @return 实验器材申请
     */
    @Override
    public AlgsEquipmentApplication selectAlgsEquipmentApplicationByEquipmentApplicationId(Long equipmentApplicationId)
    {
        return algsEquipmentApplicationMapper.selectAlgsEquipmentApplicationByEquipmentApplicationId(equipmentApplicationId);
    }

    /**
     * 查询实验器材申请列表
     * 
     * @param algsEquipmentApplication 实验器材申请
     * @return 实验器材申请
     */
    @Override
    public List<AlgsEquipmentApplication> selectAlgsEquipmentApplicationList(AlgsEquipmentApplication algsEquipmentApplication)
    {
        return algsEquipmentApplicationMapper.selectAlgsEquipmentApplicationList(algsEquipmentApplication);
    }

    /**
     * 新增实验器材申请
     * 
     * @param algsEquipmentApplication 实验器材申请
     * @return 结果
     */
    @Override
    public int insertAlgsEquipmentApplication(AlgsEquipmentApplication algsEquipmentApplication)
    {
        return algsEquipmentApplicationMapper.insertAlgsEquipmentApplication(algsEquipmentApplication);
    }

    /**
     * 修改实验器材申请
     * 
     * @param algsEquipmentApplication 实验器材申请
     * @return 结果
     */
    @Override
    public int updateAlgsEquipmentApplication(AlgsEquipmentApplication algsEquipmentApplication)
    {
        return algsEquipmentApplicationMapper.updateAlgsEquipmentApplication(algsEquipmentApplication);
    }

    /**
     * 批量删除实验器材申请
     * 
     * @param equipmentApplicationIds 需要删除的实验器材申请主键
     * @return 结果
     */
    @Override
    public int deleteAlgsEquipmentApplicationByEquipmentApplicationIds(Long[] equipmentApplicationIds)
    {
        return algsEquipmentApplicationMapper.deleteAlgsEquipmentApplicationByEquipmentApplicationIds(equipmentApplicationIds);
    }

    /**
     * 删除实验器材申请信息
     * 
     * @param equipmentApplicationId 实验器材申请主键
     * @return 结果
     */
    @Override
    public int deleteAlgsEquipmentApplicationByEquipmentApplicationId(Long equipmentApplicationId)
    {
        return algsEquipmentApplicationMapper.deleteAlgsEquipmentApplicationByEquipmentApplicationId(equipmentApplicationId);
    }

    @Override
    public int addE(Long equipmentApplicationId) {
        AlgsEquipmentApplication algsEquipmentApplication = algsEquipmentApplicationMapper.selectAlgsEquipmentApplicationByEquipmentApplicationId(equipmentApplicationId);
        AlgsEquipmentConsent algsEquipmentConsent = new AlgsEquipmentConsent();
        algsEquipmentConsent.setEquipmentApplicationId(algsEquipmentApplication.getEquipmentApplicationId());
        algsEquipmentConsent.setEquipmentApplicationName(algsEquipmentApplication.getEquipmentApplicationName());
        algsEquipmentConsent.setEquipmentApplicationDate(algsEquipmentApplication.getEquipmentApplicationDate());
        algsEquipmentConsent.setEquipmentApplicationReturn(algsEquipmentApplication.getEquipmentApplicationReturn());
        algsEquipmentConsent.setEquipmentApplicationBy2(algsEquipmentApplication.getEquipmentApplicationBy1());
        algsEquipmentConsent.setEquipmentApplicationNum(algsEquipmentApplication.getEquipmentApplicationNum());
        algsEquipmentConsent.setEquipmentApplicationLaterdate(algsEquipmentApplication.getEquipmentApplicationUseTime());
//        algsEquipmentConsent1.insertAlgsEquipmentConsent(algsEquipmentConsent);
        Long aLong = Long.valueOf(1);
        algsEquipmentApplication.setEquipmentApplicationBy3(aLong);
        System.out.println(algsEquipmentApplication);
        algsEquipmentApplicationMapper.updateAlgsEquipmentApplication(algsEquipmentApplication);
        return algsEquipmentConsent1.insertAlgsEquipmentConsent(algsEquipmentConsent);
    }
}
